package com.webdev.newtech.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.webdev.newtech.domain.TlCat;
import com.webdev.newtech.mapper.ITlCatMapper;
import com.webdev.newtech.service.ITlCatService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class ITlCatServiceImpl implements ITlCatService {
    @Resource
    ITlCatMapper catMapper;


    @Override
    public int add(TlCat cat) {
        return catMapper.insert(cat);
    }

    @Override
    public int remove(Integer id) {
        return catMapper.deleteById(id);
    }

    @Override
    public int update(TlCat cat) {
        return catMapper.updateById(cat);
    }

    @Override
    public List<TlCat> getList(TlCat cat) {
        QueryWrapper<TlCat>wrapper=new QueryWrapper<>();
        wrapper.eq(cat.getStatus()!=null,"status",cat.getStatus() );
        wrapper.orderByAsc("order_num");
        return catMapper.selectList(wrapper);
    }

    @Override
    public TlCat getById(Integer id) {
        return catMapper.selectById(id);
    }
}
